#include <bits/stdc++.h>
using namespace std;
int n,m,l,v;
struct car
{
    double d,v,a;
    double s,e;
}c[100005];
int scanner[100005];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    scanf("%d",&t);
    while(t--){
        scanf("%d%d%d%d",&n,&m,&l,&v);
        for(int i=1;i<=n;i++){
            scanf("%lf%lf%lf",&c[i].d,&c[i].v,&c[i].a);
            if(c[i].v>v){
                c[i].s=c[i].d;
                if(c[i].a<0){
                    c[i].e=c[i].d+(pow(v,2)-pow(c[i].v,2))/(2*c[i].a);
                    if(c[i].e>l){
                        c[i].e=l;
                    }
                }else{
                    c[i].e=l;
                }
            }else{
                if(c[i].a<=0){
                    c[i].s=-1;
                    c[i].e=-1;
                }else{
                    c[i].s=c[i].d+(pow(v,2)-pow(c[i].v,2))/(2*c[i].a);
                    if(c[i].s>l){
                        c[i].s=-1;
                        c[i].e=-1;
                    }else{
                        c[i].e=l;
                    }
                }
            }
        }
        for(int i=1;i<=m;i++){
            scanf("%d",&scanner[i]);
        }
        int ans=0;
        for(int i=1;i<=n;i++){
            if(c[i].s==-1){
                continue;
            }
            int st=upper_bound(scanner+1,scanner+m+1,c[i].s)-scanner;
            int ed=lower_bound(scanner+1,scanner+m+1,c[i].e)-scanner;
            if(st<ed||(st==ed&&scanner[ed]!=c[i].e)){
                ans++;
            }
        }
        cout<<ans<<" "<<m-1<<endl;
    }

    return 0;
}